There appears to be significant difference in the rate of bad variable naming between the low and high debt groups.
d.both_completed %>%
ggplot(aes(x=var_names_new_good.ratio, fill=high_debt_version)) +
geom_boxplot() +
labs(
title = "Distribution of good variable naming rate for the different debt levels (new variables)",
x ="Ratio of good variable name selection"
) +
scale_y_continuous(breaks = NULL) +
scale_fill_manual(
name = "Debt level",
labels = c("High debt", "Low debt"),
values = c("#7070FF", "lightblue"),
guide = guide_legend(reverse = TRUE)
)
d.both_completed %>%
ggplot(aes(x=var_names_copied_good.ratio, fill=high_debt_version)) +
geom_boxplot() +
labs(
title = "Distribution of good variable naming rate for the different debt levels (copied variables)",
x ="Ratio of good variable name selection"
) +
scale_y_continuous(breaks = NULL) +
scale_fill_manual(
name = "Debt level",
labels = c("High debt", "Low debt"),
values = c("#7070FF", "lightblue"),
guide = guide_legend(reverse = TRUE)
)
d.both_completed %>%
pull(var_names_new_good.ratio) %>%
summary()
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0000 1.0000 1.0000 0.8425 1.0000 1.0000
sprintf("Variance: %.2f", var(pull(d.both_completed, var_names_new_good.ratio)))
## [1] "Variance: 0.10"
d.both_completed %>%
pull(var_names_copied_good.ratio) %>%
summary()
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0000 0.1215 1.0000 0.6556 1.0000 1.0000
sprintf("Variance: %.2f", var(pull(d.both_completed, var_names_copied_good.ratio)))
## [1] "Variance: 0.18"
Variable names are modeled using the binomial family, where the amount of trials is the total amount of new/copied variable names.
We include high_debt_verison as well as a varying intercept for each individual in our initial model.
We iterate over the model until we have sane priors, in this case a prior giving a 50/50 chance was chosen in both cases. The prior “lkj(2)” will mean the model is skeptical of strong correlations.
variable_names.with <- extendable_model(
base_name = "variable_names",
base_formula = "var_names_new_good | trials(var_names_new_all) ~ 1 + high_debt_version + (1 | session)",
base_priors = c(
prior(normal(0, 1), class = "b"),
prior(normal(2, 1), class = "Intercept"),
prior(exponential(1), class = "sd")
),
family = binomial(),
data = d.both_completed,
base_control = list(adapt_delta = 0.95)
)
prior_summary(variable_names.with(only_priors= TRUE))
prior_summary(variable_names.with(sample_prior = "only"))
pp_check(variable_names.with(sample_prior = "only"), nsamples = 200)
sim.size <- 1000
sim.intercept <- rnorm(sim.size, 2, 1)
sim.beta <- rnorm(sim.size, 0, 1)
sim.beta.diff <- (plogis(sim.intercept + sim.beta) / plogis(sim.intercept) * 100) - 100
data.frame(x = sim.beta.diff) %>%
ggplot(aes(x)) +
geom_density() +
xlim(-80, 80) +
labs(
title = "Beta parameter prior influence",
x = "Estimate with beta as % of estimate without beta",
y = "Density"
)
We check the posterior distribution and can see that the model seems to have been able to fit the data well Sampling seems to also have worked well as Rhat values are close to 1 and the sampling plots look nice.
pp_check(variable_names.with(), nsamples = 200, type = "bars")
summary(variable_names.with())
## Family: binomial
## Links: mu = logit
## Formula: var_names_new_good | trials(var_names_new_all) ~ 1 + high_debt_version + (1 | session)
## Data: as.data.frame(data) (Number of observations: 44)
## Samples: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
## total post-warmup samples = 4000
##
## Group-Level Effects:
## ~session (Number of levels: 22)
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept) 1.76 0.62 0.77 3.22 1.00 1556 1954
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept 1.50 0.49 0.62 2.56 1.00 2138
## high_debt_versionfalse 2.40 0.56 1.34 3.53 1.00 4940
## Tail_ESS
## Intercept 2444
## high_debt_versionfalse 3324
##
## Samples were drawn using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
plot(variable_names.with(), ask = FALSE)
# default prior for monotonic predictor
edlvl_prior <- prior(dirichlet(2), class = "simo", coef = "moeducation_level1")
loo_result <- loo(
# Benchmark model(s)
variable_names.with(),
# New model(s)
variable_names.with("work_domain"),
variable_names.with("work_experience_programming.s"),
variable_names.with("work_experience_java.s"),
variable_names.with("education_field"),
variable_names.with("mo(education_level)", edlvl_prior),
variable_names.with("workplace_peer_review"),
variable_names.with("workplace_td_tracking"),
variable_names.with("workplace_pair_programming"),
variable_names.with("workplace_coding_standards"),
variable_names.with("scenario"),
variable_names.with("group")
)
loo_result[2]
## $diffs
## elpd_diff se_diff
## variable_names.with("work_experience_programming.s") 0.0 0.0
## variable_names.with("education_field") -0.1 1.2
## variable_names.with("workplace_pair_programming") -0.3 0.4
## variable_names.with("work_experience_java.s") -0.3 0.4
## variable_names.with("workplace_td_tracking") -0.5 0.5
## variable_names.with("workplace_peer_review") -0.6 0.5
## variable_names.with() -0.7 0.5
## variable_names.with("scenario") -0.9 1.2
## variable_names.with("group") -1.1 0.7
## variable_names.with("workplace_coding_standards") -1.2 0.6
## variable_names.with("mo(education_level)", edlvl_prior) -1.6 0.8
## variable_names.with("work_domain") -1.9 0.8
loo_result[1]
## $loos
## $loos$`variable_names.with()`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.8 6.3
## p_loo 15.3 3.0
## looic 73.6 12.6
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 23 52.3% 1439
## (0.5, 0.7] (ok) 7 15.9% 768
## (0.7, 1] (bad) 13 29.5% 52
## (1, Inf) (very bad) 1 2.3% 19
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("work_domain")`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -38.0 6.5
## p_loo 17.0 3.3
## looic 76.0 13.0
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 22 50.0% 1547
## (0.5, 0.7] (ok) 10 22.7% 145
## (0.7, 1] (bad) 12 27.3% 28
## (1, Inf) (very bad) 0 0.0% <NA>
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("work_experience_programming.s")`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.1 6.0
## p_loo 14.9 2.8
## looic 72.2 12.0
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 24 54.5% 1168
## (0.5, 0.7] (ok) 11 25.0% 135
## (0.7, 1] (bad) 9 20.5% 44
## (1, Inf) (very bad) 0 0.0% <NA>
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("work_experience_java.s")`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.4 6.2
## p_loo 15.1 2.9
## looic 72.9 12.4
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 20 45.5% 1269
## (0.5, 0.7] (ok) 18 40.9% 211
## (0.7, 1] (bad) 6 13.6% 39
## (1, Inf) (very bad) 0 0.0% <NA>
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("education_field")`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.2 6.0
## p_loo 13.3 2.4
## looic 72.4 11.9
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 21 47.7% 710
## (0.5, 0.7] (ok) 15 34.1% 201
## (0.7, 1] (bad) 8 18.2% 44
## (1, Inf) (very bad) 0 0.0% <NA>
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("mo(education_level)", edlvl_prior)`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -37.7 6.5
## p_loo 16.3 3.2
## looic 75.4 13.1
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 23 52.3% 1528
## (0.5, 0.7] (ok) 12 27.3% 118
## (0.7, 1] (bad) 7 15.9% 30
## (1, Inf) (very bad) 2 4.5% 21
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("workplace_peer_review")`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.7 6.2
## p_loo 15.3 2.9
## looic 73.3 12.5
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 19 43.2% 1559
## (0.5, 0.7] (ok) 14 31.8% 647
## (0.7, 1] (bad) 11 25.0% 39
## (1, Inf) (very bad) 0 0.0% <NA>
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("workplace_td_tracking")`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.6 6.1
## p_loo 15.2 2.9
## looic 73.2 12.3
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 22 50.0% 1151
## (0.5, 0.7] (ok) 11 25.0% 433
## (0.7, 1] (bad) 10 22.7% 52
## (1, Inf) (very bad) 1 2.3% 87
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("workplace_pair_programming")`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.4 6.2
## p_loo 15.0 2.9
## looic 72.9 12.4
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 25 56.8% 1223
## (0.5, 0.7] (ok) 9 20.5% 183
## (0.7, 1] (bad) 9 20.5% 77
## (1, Inf) (very bad) 1 2.3% 23
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("workplace_coding_standards")`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -37.3 6.4
## p_loo 15.8 3.1
## looic 74.5 12.9
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 23 52.3% 1290
## (0.5, 0.7] (ok) 10 22.7% 204
## (0.7, 1] (bad) 9 20.5% 54
## (1, Inf) (very bad) 2 4.5% 20
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("scenario")`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -37.0 6.2
## p_loo 15.9 3.0
## looic 74.0 12.4
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 24 54.5% 1388
## (0.5, 0.7] (ok) 10 22.7% 246
## (0.7, 1] (bad) 9 20.5% 63
## (1, Inf) (very bad) 1 2.3% 11
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("group")`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -37.2 6.5
## p_loo 16.2 3.3
## looic 74.4 13.0
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 22 50.0% 1073
## (0.5, 0.7] (ok) 13 29.5% 247
## (0.7, 1] (bad) 8 18.2% 27
## (1, Inf) (very bad) 1 2.3% 15
## See help('pareto-k-diagnostic') for details.
loo_result <- loo(
# Benchmark model(s)
variable_names.with(),
variable_names.with("work_experience_programming.s"),
variable_names.with("education_field"),
variable_names.with("work_experience_java.s"),
variable_names.with("workplace_pair_programming"),
# New model(s)
variable_names.with(c("work_experience_programming.s", "education_field")),
variable_names.with(c("work_experience_programming.s", "work_experience_java.s")),
variable_names.with(c("work_experience_programming.s", "workplace_pair_programming")),
variable_names.with(c("education_field", "work_experience_java.s")),
variable_names.with(c("education_field", "workplace_pair_programming")),
variable_names.with(c("work_experience_java.s", "workplace_pair_programming"))
)
loo_result[2]
## $diffs
## elpd_diff
## variable_names.with("work_experience_programming.s") 0.0
## variable_names.with("education_field") -0.1
## variable_names.with("workplace_pair_programming") -0.3
## variable_names.with("work_experience_java.s") -0.3
## variable_names.with(c("education_field", "workplace_pair_programming")) -0.3
## variable_names.with(c("work_experience_programming.s", "education_field")) -0.5
## variable_names.with(c("education_field", "work_experience_java.s")) -0.7
## variable_names.with() -0.7
## variable_names.with(c("work_experience_programming.s", "work_experience_java.s")) -0.8
## variable_names.with(c("work_experience_programming.s", "workplace_pair_programming")) -1.4
## variable_names.with(c("work_experience_java.s", "workplace_pair_programming")) -1.8
## se_diff
## variable_names.with("work_experience_programming.s") 0.0
## variable_names.with("education_field") 1.2
## variable_names.with("workplace_pair_programming") 0.4
## variable_names.with("work_experience_java.s") 0.4
## variable_names.with(c("education_field", "workplace_pair_programming")) 1.1
## variable_names.with(c("work_experience_programming.s", "education_field")) 1.1
## variable_names.with(c("education_field", "work_experience_java.s")) 1.1
## variable_names.with() 0.5
## variable_names.with(c("work_experience_programming.s", "work_experience_java.s")) 0.5
## variable_names.with(c("work_experience_programming.s", "workplace_pair_programming")) 0.7
## variable_names.with(c("work_experience_java.s", "workplace_pair_programming")) 0.8
loo_result[1]
## $loos
## $loos$`variable_names.with()`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.8 6.3
## p_loo 15.3 3.0
## looic 73.6 12.6
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 23 52.3% 1439
## (0.5, 0.7] (ok) 7 15.9% 768
## (0.7, 1] (bad) 13 29.5% 52
## (1, Inf) (very bad) 1 2.3% 19
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("work_experience_programming.s")`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.1 6.0
## p_loo 14.9 2.8
## looic 72.2 12.0
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 24 54.5% 1168
## (0.5, 0.7] (ok) 11 25.0% 135
## (0.7, 1] (bad) 9 20.5% 44
## (1, Inf) (very bad) 0 0.0% <NA>
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("education_field")`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.2 6.0
## p_loo 13.3 2.4
## looic 72.4 11.9
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 21 47.7% 710
## (0.5, 0.7] (ok) 15 34.1% 201
## (0.7, 1] (bad) 8 18.2% 44
## (1, Inf) (very bad) 0 0.0% <NA>
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("work_experience_java.s")`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.4 6.2
## p_loo 15.1 2.9
## looic 72.9 12.4
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 20 45.5% 1269
## (0.5, 0.7] (ok) 18 40.9% 211
## (0.7, 1] (bad) 6 13.6% 39
## (1, Inf) (very bad) 0 0.0% <NA>
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("workplace_pair_programming")`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.4 6.2
## p_loo 15.0 2.9
## looic 72.9 12.4
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 25 56.8% 1223
## (0.5, 0.7] (ok) 9 20.5% 183
## (0.7, 1] (bad) 9 20.5% 77
## (1, Inf) (very bad) 1 2.3% 23
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with(c("work_experience_programming.s", "education_field"))`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.6 6.1
## p_loo 14.3 2.7
## looic 73.1 12.1
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 22 50.0% 806
## (0.5, 0.7] (ok) 13 29.5% 301
## (0.7, 1] (bad) 7 15.9% 115
## (1, Inf) (very bad) 2 4.5% 16
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with(c("work_experience_programming.s", "work_experience_java.s"))`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.9 6.2
## p_loo 15.7 3.0
## looic 73.8 12.5
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 21 47.7% 1039
## (0.5, 0.7] (ok) 12 27.3% 109
## (0.7, 1] (bad) 10 22.7% 66
## (1, Inf) (very bad) 1 2.3% 17
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with(c("work_experience_programming.s", "workplace_pair_programming"))`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -37.5 6.5
## p_loo 16.4 3.3
## looic 75.0 13.0
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 22 50.0% 1795
## (0.5, 0.7] (ok) 10 22.7% 298
## (0.7, 1] (bad) 9 20.5% 55
## (1, Inf) (very bad) 3 6.8% 9
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with(c("education_field", "work_experience_java.s"))`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.8 6.1
## p_loo 14.3 2.6
## looic 73.6 12.2
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 23 52.3% 595
## (0.5, 0.7] (ok) 11 25.0% 295
## (0.7, 1] (bad) 9 20.5% 60
## (1, Inf) (very bad) 1 2.3% 45
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with(c("education_field", "workplace_pair_programming"))`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.5 6.1
## p_loo 14.0 2.6
## looic 72.9 12.1
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 24 54.5% 886
## (0.5, 0.7] (ok) 13 29.5% 154
## (0.7, 1] (bad) 7 15.9% 71
## (1, Inf) (very bad) 0 0.0% <NA>
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with(c("work_experience_java.s", "workplace_pair_programming"))`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -37.9 6.5
## p_loo 16.7 3.2
## looic 75.7 13.0
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 23 52.3% 1197
## (0.5, 0.7] (ok) 10 22.7% 106
## (0.7, 1] (bad) 9 20.5% 47
## (1, Inf) (very bad) 2 4.5% 8
## See help('pareto-k-diagnostic') for details.
loo_result <- loo(
# Benchmark model(s)
variable_names.with(),
variable_names.with("work_experience_programming.s"),
variable_names.with("education_field"),
variable_names.with("work_experience_java.s"),
variable_names.with("workplace_pair_programming"),
variable_names.with(c("work_experience_programming.s", "education_field")),
variable_names.with(c("education_field", "work_experience_java.s")),
variable_names.with(c("education_field", "workplace_pair_programming")),
# New model(s)
variable_names.with(c("education_field", "work_experience_programming.s", "work_experience_java.s")),
variable_names.with(c("education_field", "work_experience_programming.s", "workplace_pair_programming")),
variable_names.with(c("education_field", "work_experience_java.s", "workplace_pair_programming"))
)
loo_result[2]
## $diffs
## elpd_diff
## variable_names.with(c("education_field", "work_experience_programming.s", "workplace_pair_programming")) 0.0
## variable_names.with("work_experience_programming.s") -0.2
## variable_names.with("education_field") -0.3
## variable_names.with(c("education_field", "work_experience_programming.s", "work_experience_java.s")) -0.4
## variable_names.with("workplace_pair_programming") -0.5
## variable_names.with("work_experience_java.s") -0.5
## variable_names.with(c("education_field", "workplace_pair_programming")) -0.5
## variable_names.with(c("education_field", "work_experience_java.s", "workplace_pair_programming")) -0.6
## variable_names.with(c("work_experience_programming.s", "education_field")) -0.7
## variable_names.with(c("education_field", "work_experience_java.s")) -0.9
## variable_names.with() -0.9
## se_diff
## variable_names.with(c("education_field", "work_experience_programming.s", "workplace_pair_programming")) 0.0
## variable_names.with("work_experience_programming.s") 0.9
## variable_names.with("education_field") 0.6
## variable_names.with(c("education_field", "work_experience_programming.s", "work_experience_java.s")) 0.5
## variable_names.with("workplace_pair_programming") 1.0
## variable_names.with("work_experience_java.s") 1.0
## variable_names.with(c("education_field", "workplace_pair_programming")) 0.5
## variable_names.with(c("education_field", "work_experience_java.s", "workplace_pair_programming")) 0.4
## variable_names.with(c("work_experience_programming.s", "education_field")) 0.6
## variable_names.with(c("education_field", "work_experience_java.s")) 0.4
## variable_names.with() 1.1
loo_result[1]
## $loos
## $loos$`variable_names.with()`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.8 6.3
## p_loo 15.3 3.0
## looic 73.6 12.6
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 23 52.3% 1439
## (0.5, 0.7] (ok) 7 15.9% 768
## (0.7, 1] (bad) 13 29.5% 52
## (1, Inf) (very bad) 1 2.3% 19
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("work_experience_programming.s")`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.1 6.0
## p_loo 14.9 2.8
## looic 72.2 12.0
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 24 54.5% 1168
## (0.5, 0.7] (ok) 11 25.0% 135
## (0.7, 1] (bad) 9 20.5% 44
## (1, Inf) (very bad) 0 0.0% <NA>
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("education_field")`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.2 6.0
## p_loo 13.3 2.4
## looic 72.4 11.9
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 21 47.7% 710
## (0.5, 0.7] (ok) 15 34.1% 201
## (0.7, 1] (bad) 8 18.2% 44
## (1, Inf) (very bad) 0 0.0% <NA>
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("work_experience_java.s")`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.4 6.2
## p_loo 15.1 2.9
## looic 72.9 12.4
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 20 45.5% 1269
## (0.5, 0.7] (ok) 18 40.9% 211
## (0.7, 1] (bad) 6 13.6% 39
## (1, Inf) (very bad) 0 0.0% <NA>
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with("workplace_pair_programming")`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.4 6.2
## p_loo 15.0 2.9
## looic 72.9 12.4
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 25 56.8% 1223
## (0.5, 0.7] (ok) 9 20.5% 183
## (0.7, 1] (bad) 9 20.5% 77
## (1, Inf) (very bad) 1 2.3% 23
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with(c("work_experience_programming.s", "education_field"))`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.6 6.1
## p_loo 14.3 2.7
## looic 73.1 12.1
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 22 50.0% 806
## (0.5, 0.7] (ok) 13 29.5% 301
## (0.7, 1] (bad) 7 15.9% 115
## (1, Inf) (very bad) 2 4.5% 16
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with(c("education_field", "work_experience_java.s"))`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.8 6.1
## p_loo 14.3 2.6
## looic 73.6 12.2
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 23 52.3% 595
## (0.5, 0.7] (ok) 11 25.0% 295
## (0.7, 1] (bad) 9 20.5% 60
## (1, Inf) (very bad) 1 2.3% 45
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with(c("education_field", "workplace_pair_programming"))`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.5 6.1
## p_loo 14.0 2.6
## looic 72.9 12.1
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 24 54.5% 886
## (0.5, 0.7] (ok) 13 29.5% 154
## (0.7, 1] (bad) 7 15.9% 71
## (1, Inf) (very bad) 0 0.0% <NA>
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with(c("education_field", "work_experience_programming.s", "work_experience_java.s"))`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.4 6.0
## p_loo 14.2 2.5
## looic 72.7 11.9
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 22 50.0% 552
## (0.5, 0.7] (ok) 15 34.1% 200
## (0.7, 1] (bad) 7 15.9% 28
## (1, Inf) (very bad) 0 0.0% <NA>
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with(c("education_field", "work_experience_programming.s", "workplace_pair_programming"))`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -35.9 5.9
## p_loo 14.2 2.6
## looic 71.8 11.9
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 20 45.5% 892
## (0.5, 0.7] (ok) 18 40.9% 150
## (0.7, 1] (bad) 6 13.6% 52
## (1, Inf) (very bad) 0 0.0% <NA>
## See help('pareto-k-diagnostic') for details.
##
## $loos$`variable_names.with(c("education_field", "work_experience_java.s", "workplace_pair_programming"))`
##
## Computed from 4000 by 44 log-likelihood matrix
##
## Estimate SE
## elpd_loo -36.6 6.1
## p_loo 14.6 2.6
## looic 73.1 12.1
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 23 52.3% 705
## (0.5, 0.7] (ok) 9 20.5% 410
## (0.7, 1] (bad) 12 27.3% 43
## (1, Inf) (very bad) 0 0.0% <NA>
## See help('pareto-k-diagnostic') for details.
We pick some of our top performing models as candidates and inspect them closer.
The candidate models are named and listed in order of complexity.
We select the simplest model as a baseline.
variable_names0 <- brm(
"var_names_new_good | trials(var_names_new_all) ~ 1 + high_debt_version + (1 | session)",
prior = c(
prior(normal(0, 1), class = "b"),
prior(normal(2, 1), class = "Intercept"),
prior(exponential(1), class = "sd")
),
family = binomial(),
data = d.both_completed,
control = list(adapt_delta = 0.95),
file = "fits/variable_names0",
file_refit = "on_change",
seed = 20210421
)
summary(variable_names0)
## Family: binomial
## Links: mu = logit
## Formula: var_names_new_good | trials(var_names_new_all) ~ 1 + high_debt_version + (1 | session)
## Data: d.both_completed (Number of observations: 44)
## Samples: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
## total post-warmup samples = 4000
##
## Group-Level Effects:
## ~session (Number of levels: 22)
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept) 1.76 0.62 0.77 3.22 1.00 1556 1954
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept 1.50 0.49 0.62 2.56 1.00 2138
## high_debt_versionfalse 2.40 0.56 1.34 3.53 1.00 4940
## Tail_ESS
## Intercept 2444
## high_debt_versionfalse 3324
##
## Samples were drawn using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
ranef(variable_names0)
## $session
## , , Intercept
##
## Estimate Est.Error Q2.5 Q97.5
## 6033d69a5af2c702367b3a95 1.0053017 1.4725852 -1.4096925 4.39573375
## 6033d90a5af2c702367b3a96 1.2801018 1.4441882 -1.1246312 4.62251600
## 6034fc165af2c702367b3a98 -1.3752590 0.6441327 -2.7361123 -0.18024937
## 603500725af2c702367b3a99 -1.5026860 1.0659209 -3.6999145 0.44977570
## 603f97625af2c702367b3a9d 1.2817994 1.4204722 -1.0033355 4.66576575
## 603fd5d95af2c702367b3a9e -1.4766295 1.0622771 -3.6062512 0.52589340
## 60409b7b5af2c702367b3a9f 1.2594284 1.4404332 -1.0333002 4.59310575
## 604b82b5a7718fbed181b336 -0.8745753 0.8378813 -2.5547547 0.71374037
## 6050c1bf856f36729d2e5218 -1.8528959 0.9965726 -3.9075195 0.02309354
## 6050e1e7856f36729d2e5219 1.2446659 1.4196629 -1.0637573 4.61087175
## 6055fdc6856f36729d2e521b 0.9781706 1.4669427 -1.5159412 4.34514275
## 60589862856f36729d2e521f 1.0583686 1.5113983 -1.3007750 4.53715525
## 605afa3a856f36729d2e5222 -1.6005988 1.0880695 -3.8428432 0.45247855
## 605c8bc6856f36729d2e5223 -0.9422695 0.9933346 -2.9926905 1.01807100
## 605f3f2d856f36729d2e5224 1.0053400 1.5407596 -1.4655085 4.52461425
## 605f46c3856f36729d2e5225 -1.6095482 0.8806209 -3.4153403 0.08768378
## 60605337856f36729d2e5226 0.9893993 1.4699536 -1.3810502 4.42812150
## 60609ae6856f36729d2e5228 1.2911315 1.4595185 -1.0052215 4.65062050
## 6061ce91856f36729d2e522e 1.2535660 1.4644023 -1.0365243 4.66029375
## 6061f106856f36729d2e5231 -1.5080077 1.0744646 -3.6927935 0.53988378
## 6068ea9f856f36729d2e523e 1.6030035 1.3759292 -0.5242253 4.86091700
## 6075ab05856f36729d2e5247 1.2917775 1.4157909 -0.9532526 4.52116525
plot(variable_names0, ask = FALSE)
pp_check(variable_names0, nsamples = 200, type = "bars")
We select the best performing model with one variable.
variable_names1 <- brm(
"var_names_new_good | trials(var_names_new_all) ~ 1 + high_debt_version + work_experience_programming.s + (1 | session)",
prior = c(
prior(normal(0, 1), class = "b"),
prior(normal(2, 1), class = "Intercept"),
prior(exponential(1), class = "sd")
),
family = binomial(),
data = d.both_completed,
control = list(adapt_delta = 0.95),
file = "fits/variable_names1",
file_refit = "on_change",
seed = 20210421
)
summary(variable_names1)
## Family: binomial
## Links: mu = logit
## Formula: var_names_new_good | trials(var_names_new_all) ~ 1 + high_debt_version + work_experience_programming.s + (1 | session)
## Data: d.both_completed (Number of observations: 44)
## Samples: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
## total post-warmup samples = 4000
##
## Group-Level Effects:
## ~session (Number of levels: 22)
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept) 1.85 0.64 0.83 3.36 1.01 1277 1929
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI Rhat
## Intercept 1.54 0.52 0.61 2.66 1.00
## high_debt_versionfalse 2.42 0.58 1.30 3.62 1.00
## work_experience_programming.s 0.05 0.50 -0.95 1.07 1.00
## Bulk_ESS Tail_ESS
## Intercept 2350 2823
## high_debt_versionfalse 3926 2792
## work_experience_programming.s 2667 2332
##
## Samples were drawn using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
ranef(variable_names1)
## $session
## , , Intercept
##
## Estimate Est.Error Q2.5 Q97.5
## 6033d69a5af2c702367b3a95 1.0649471 1.5950601 -1.5887855 4.80293250
## 6033d90a5af2c702367b3a96 1.3614543 1.4555544 -1.0245270 4.65225975
## 6034fc165af2c702367b3a98 -1.3840836 0.6867982 -2.8232793 -0.09705970
## 603500725af2c702367b3a99 -1.5545818 1.1389219 -3.8494015 0.61042228
## 603f97625af2c702367b3a9d 1.3774100 1.5282312 -1.0199505 4.96795950
## 603fd5d95af2c702367b3a9e -1.5771957 1.1313146 -3.8650600 0.53641495
## 60409b7b5af2c702367b3a9f 1.3360972 1.5038100 -1.0802010 4.73077750
## 604b82b5a7718fbed181b336 -0.9145851 0.8520321 -2.6406020 0.68581373
## 6050c1bf856f36729d2e5218 -1.9488459 1.0303142 -4.1110328 -0.06842290
## 6050e1e7856f36729d2e5219 1.3278557 1.4645969 -1.0882795 4.76211175
## 6055fdc6856f36729d2e521b 1.0514741 1.5851166 -1.4943090 4.53607050
## 60589862856f36729d2e521f 1.1183202 1.6199911 -1.7855962 4.74122825
## 605afa3a856f36729d2e5222 -1.6928495 1.3031141 -4.4739403 0.67558605
## 605c8bc6856f36729d2e5223 -1.0176432 1.0098416 -3.0823650 0.91251700
## 605f3f2d856f36729d2e5224 1.1233403 1.7127426 -1.9781222 5.01562275
## 605f46c3856f36729d2e5225 -1.6549721 0.9186668 -3.5705062 0.02911496
## 60605337856f36729d2e5226 1.0660473 1.5248441 -1.4421765 4.75227825
## 60609ae6856f36729d2e5228 1.3564359 1.4879457 -0.9760470 4.81332550
## 6061ce91856f36729d2e522e 1.3344295 1.4574278 -1.0403522 4.81347450
## 6061f106856f36729d2e5231 -1.5466717 1.1195944 -3.7799853 0.70708073
## 6068ea9f856f36729d2e523e 1.6680985 1.4429281 -0.5923771 5.16929200
## 6075ab05856f36729d2e5247 1.3035829 1.4272692 -1.0265287 4.55845350
plot(variable_names1, ask = FALSE)
pp_check(variable_names1, nsamples = 200, type = "bars")
We select the second best performing model with one variable.
variable_names2 <- brm(
"var_names_new_good | trials(var_names_new_all) ~ 1 + high_debt_version + education_field + (1 | session)",
prior = c(
prior(normal(0, 1), class = "b"),
prior(normal(2, 1), class = "Intercept"),
prior(exponential(1), class = "sd")
),
family = binomial(),
data = d.both_completed,
control = list(adapt_delta = 0.95),
file = "fits/variable_names2",
file_refit = "on_change",
seed = 20210421
)
summary(variable_names2)
## Family: binomial
## Links: mu = logit
## Formula: var_names_new_good | trials(var_names_new_all) ~ 1 + high_debt_version + education_field + (1 | session)
## Data: d.both_completed (Number of observations: 44)
## Samples: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
## total post-warmup samples = 4000
##
## Group-Level Effects:
## ~session (Number of levels: 22)
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept) 1.37 0.67 0.16 2.87 1.01 745 638
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI Rhat
## Intercept 2.16 0.67 0.89 3.56 1.00
## high_debt_versionfalse 2.33 0.59 1.22 3.52 1.00
## education_fieldInteractionDesign 0.31 0.95 -1.53 2.21 1.00
## education_fieldNone 0.42 0.92 -1.38 2.24 1.00
## education_fieldSoftwareEngineering -1.13 0.72 -2.47 0.32 1.00
## Bulk_ESS Tail_ESS
## Intercept 3804 3326
## high_debt_versionfalse 4545 3093
## education_fieldInteractionDesign 4850 2720
## education_fieldNone 4842 2785
## education_fieldSoftwareEngineering 3439 2676
##
## Samples were drawn using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
ranef(variable_names2)
## $session
## , , Intercept
##
## Estimate Est.Error Q2.5 Q97.5
## 6033d69a5af2c702367b3a95 0.5337078 1.3144733 -1.6534035 3.6747870
## 6033d90a5af2c702367b3a96 1.1017061 1.2587574 -0.7982545 4.0442035
## 6034fc165af2c702367b3a98 -0.8685059 0.6536449 -2.2751128 0.2434865
## 603500725af2c702367b3a99 -0.9722472 1.0065555 -3.1380435 0.6766352
## 603f97625af2c702367b3a9d 0.7455080 1.2634789 -1.3279367 3.7951462
## 603fd5d95af2c702367b3a9e -0.9777154 1.0110159 -3.2030175 0.7300317
## 60409b7b5af2c702367b3a9f 1.0899307 1.2455617 -0.7775885 4.1965263
## 604b82b5a7718fbed181b336 -0.4658392 0.7847496 -2.1372995 0.9839604
## 6050c1bf856f36729d2e5218 -1.2484159 1.0006167 -3.3149520 0.3837126
## 6050e1e7856f36729d2e5219 1.1069155 1.2654468 -0.8352665 4.1803223
## 6055fdc6856f36729d2e521b 0.5817286 1.3676246 -1.6905730 3.8439193
## 60589862856f36729d2e521f 0.9119655 1.2653343 -1.1126930 3.9424843
## 605afa3a856f36729d2e5222 -1.5731946 1.2139613 -4.1619922 0.3072761
## 605c8bc6856f36729d2e5223 -0.5021277 0.8892337 -2.3957445 1.1825533
## 605f3f2d856f36729d2e5224 0.5299980 1.2819133 -1.5937680 3.5006768
## 605f46c3856f36729d2e5225 -1.0744857 0.8904616 -2.9223705 0.4162331
## 60605337856f36729d2e5226 0.8669553 1.3015846 -1.1756743 4.0855378
## 60609ae6856f36729d2e5228 0.7140101 1.2852688 -1.3705670 3.7601420
## 6061ce91856f36729d2e522e 1.1046824 1.2425765 -0.6857765 4.0806555
## 6061f106856f36729d2e5231 -0.9819158 0.9874415 -3.1435498 0.7162144
## 6068ea9f856f36729d2e523e 0.8239776 1.3205497 -1.3379505 3.9402578
## 6075ab05856f36729d2e5247 0.7036701 1.3712148 -1.4701295 3.9567323
plot(variable_names2, ask = FALSE)
pp_check(variable_names2, nsamples = 200, type = "bars")
We select the best performing model with three variable.
variable_names3 <- brm(
"var_names_new_good | trials(var_names_new_all) ~ 1 + high_debt_version + work_experience_programming.s + education_field + workplace_pair_programming + (1 | session)",
prior = c(
prior(normal(0, 1), class = "b"),
prior(normal(2, 1), class = "Intercept"),
prior(exponential(1), class = "sd")
),
family = binomial(),
data = d.both_completed,
control = list(adapt_delta = 0.95),
file = "fits/variable_names3",
file_refit = "on_change",
seed = 20210421
)
summary(variable_names3)
## Family: binomial
## Links: mu = logit
## Formula: var_names_new_good | trials(var_names_new_all) ~ 1 + high_debt_version + work_experience_programming.s + education_field + workplace_pair_programming + (1 | session)
## Data: d.both_completed (Number of observations: 44)
## Samples: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
## total post-warmup samples = 4000
##
## Group-Level Effects:
## ~session (Number of levels: 22)
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept) 1.58 0.67 0.46 3.03 1.00 1123 1340
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI Rhat
## Intercept 2.09 0.86 0.44 3.78 1.00
## high_debt_versionfalse 2.37 0.57 1.30 3.50 1.00
## work_experience_programming.s -0.05 0.49 -0.98 0.96 1.00
## education_fieldInteractionDesign 0.28 0.94 -1.52 2.13 1.00
## education_fieldNone 0.38 0.94 -1.48 2.22 1.00
## education_fieldSoftwareEngineering -1.10 0.74 -2.49 0.42 1.00
## workplace_pair_programmingfalse 0.17 0.71 -1.22 1.59 1.00
## Bulk_ESS Tail_ESS
## Intercept 3613 2935
## high_debt_versionfalse 4505 3260
## work_experience_programming.s 3301 2641
## education_fieldInteractionDesign 5571 3143
## education_fieldNone 4877 2967
## education_fieldSoftwareEngineering 3132 2740
## workplace_pair_programmingfalse 3270 2813
##
## Samples were drawn using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
ranef(variable_names3)
## $session
## , , Intercept
##
## Estimate Est.Error Q2.5 Q97.5
## 6033d69a5af2c702367b3a95 0.6254142 1.4176302 -1.8340377 3.9004663
## 6033d90a5af2c702367b3a96 1.2113123 1.3015835 -0.8750604 4.1754545
## 6034fc165af2c702367b3a98 -1.0401007 0.7260806 -2.5972150 0.2529491
## 603500725af2c702367b3a99 -1.1846580 1.1141957 -3.5555070 0.7961101
## 603f97625af2c702367b3a9d 0.8446967 1.3949446 -1.4989918 4.1190285
## 603fd5d95af2c702367b3a9e -1.0703523 1.1002870 -3.4501393 0.8645061
## 60409b7b5af2c702367b3a9f 1.1999418 1.3729911 -0.8902070 4.4092702
## 604b82b5a7718fbed181b336 -0.4802257 0.9140913 -2.4185578 1.2286840
## 6050c1bf856f36729d2e5218 -1.4903387 1.0810626 -3.8157018 0.3573020
## 6050e1e7856f36729d2e5219 1.3439558 1.4284391 -0.9062771 4.7535107
## 6055fdc6856f36729d2e521b 0.6749932 1.4496199 -1.7534292 4.0335505
## 60589862856f36729d2e521f 1.1263888 1.4816936 -1.2907420 4.6420095
## 605afa3a856f36729d2e5222 -1.8181273 1.3333060 -4.7657733 0.4593015
## 605c8bc6856f36729d2e5223 -0.6443950 0.9687208 -2.6738340 1.1777973
## 605f3f2d856f36729d2e5224 0.7777457 1.5343204 -1.9871910 4.3882755
## 605f46c3856f36729d2e5225 -1.1696300 0.9804790 -3.2921645 0.5446989
## 60605337856f36729d2e5226 1.0045704 1.3847163 -1.1903305 4.4621560
## 60609ae6856f36729d2e5228 0.8598846 1.4393244 -1.4668947 4.1070225
## 6061ce91856f36729d2e522e 1.2261056 1.3574911 -0.8558219 4.3980170
## 6061f106856f36729d2e5231 -1.1832867 1.1014126 -3.5459382 0.7575424
## 6068ea9f856f36729d2e523e 0.9745422 1.4307446 -1.3963542 4.3030500
## 6075ab05856f36729d2e5247 0.7818483 1.5142253 -1.6995935 4.2897245
plot(variable_names3, ask = FALSE)
pp_check(variable_names3, nsamples = 200, type = "bars")
All candidate models look nice, none is significantly better than the others, we will proceed the simplest model: variable_names0
We will try a few different variations of the selected candidate model.
Some participants only completed one scenario. Those has been excluded from the initial dataset to improve sampling of the models. We do however want to use all data we can and will therefore try to fit the model with the complete dataset.
Some participants only completed one scenario. Those has been excluded from the initial dataset to improve sampling of the models. We do however want to use all data we can and will therefore try to fit the model with the complete dataset.
variable_names0.all <- brm(
"var_names_new_good | trials(var_names_new_all) ~ 1 + high_debt_version + (1 | session)",
prior = c(
prior(normal(0, 1), class = "b"),
prior(normal(2, 1), class = "Intercept"),
prior(exponential(1), class = "sd")
),
family = binomial(),
data = as.data.frame(d.completed),
control = list(adapt_delta = 0.95),
file = "fits/variable_names0.all",
file_refit = "on_change",
seed = 20210421
)
summary(variable_names0.all)
## Family: binomial
## Links: mu = logit
## Formula: var_names_new_good | trials(var_names_new_all) ~ 1 + high_debt_version + (1 | session)
## Data: as.data.frame(d.completed) (Number of observations: 51)
## Samples: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
## total post-warmup samples = 4000
##
## Group-Level Effects:
## ~session (Number of levels: 29)
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept) 1.65 0.55 0.71 2.86 1.00 1313 1694
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept 1.46 0.48 0.60 2.52 1.00 2553
## high_debt_versionfalse 2.49 0.55 1.45 3.59 1.00 4893
## Tail_ESS
## Intercept 2427
## high_debt_versionfalse 2779
##
## Samples were drawn using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
ranef(variable_names0.all)
## $session
## , , Intercept
##
## Estimate Est.Error Q2.5 Q97.5
## 6033c6fc5af2c702367b3a93 -1.3763033 1.0982576 -3.7163745 0.56982008
## 6033d69a5af2c702367b3a95 0.8888425 1.3728752 -1.4633205 4.03456175
## 6033d90a5af2c702367b3a96 1.1945918 1.3738481 -1.0904098 4.35150325
## 6034fc165af2c702367b3a98 -1.3247032 0.6350449 -2.6960025 -0.17197365
## 603500725af2c702367b3a99 -1.4521591 1.1027777 -3.6403593 0.63310090
## 603f84f15af2c702367b3a9b 0.2440305 1.5653041 -2.7018852 3.65104600
## 603f97625af2c702367b3a9d 1.2222415 1.3316876 -0.9393718 4.33258675
## 603fd5d95af2c702367b3a9e -1.4335395 1.0701841 -3.6902260 0.56905953
## 60409b7b5af2c702367b3a9f 1.1750901 1.3315448 -1.0511377 4.20635075
## 604b82b5a7718fbed181b336 -0.8313375 0.8207314 -2.4721665 0.73766635
## 604f1239a7718fbed181b33f 0.8360819 1.4085476 -1.5647935 4.12472500
## 6050c1bf856f36729d2e5218 -1.8058177 0.9949212 -3.8359618 0.01492993
## 6050e1e7856f36729d2e5219 1.1621293 1.3197902 -1.0140895 4.24242725
## 6055fdc6856f36729d2e521b 0.9579258 1.4236929 -1.3922737 4.22417825
## 60579f2a856f36729d2e521e 0.2474155 1.5433587 -2.6551805 3.57870100
## 60589862856f36729d2e521f 0.9653732 1.4312276 -1.4142143 4.23727575
## 605a30a7856f36729d2e5221 0.1697913 1.6999046 -3.0347955 3.83028500
## 605afa3a856f36729d2e5222 -1.5355101 1.1066101 -3.8505460 0.48014750
## 605c8bc6856f36729d2e5223 -0.8737546 0.9441451 -2.7481985 0.96325465
## 605f3f2d856f36729d2e5224 0.9186905 1.4295961 -1.4969422 4.11923775
## 605f46c3856f36729d2e5225 -1.5447301 0.8672749 -3.3521428 0.06002432
## 60605337856f36729d2e5226 0.9104654 1.3886772 -1.4288650 4.09465350
## 60609ae6856f36729d2e5228 1.1837090 1.3698492 -0.9984386 4.52105825
## 6061ce91856f36729d2e522e 1.1664763 1.3503931 -1.0661898 4.18169100
## 6061f106856f36729d2e5231 -1.4448841 1.0688299 -3.6065583 0.56092810
## 60672faa856f36729d2e523c 0.2462275 1.5853142 -2.6984850 3.56770725
## 6068ea9f856f36729d2e523e 1.5181306 1.3025117 -0.4960703 4.61681675
## 606db69d856f36729d2e5243 0.4787293 1.4857672 -2.2055947 3.79972675
## 6075ab05856f36729d2e5247 1.1730703 1.3484890 -1.0645742 4.32641025
plot(variable_names0.all, ask = FALSE)
pp_check(variable_names0.all, nsamples = 200, type = "bars")
As including all data points didn’t harm the model we will create this variant with all data points as well.
This variation includes work_experience_programming.s predictors as it can give further insight into how experience play a factor in the effect we try to measure. This is especially important as our sampling shewed towards containing less experienced developer than the population at large.
variable_names0.all.exp <- brm(
"var_names_new_good | trials(var_names_new_all) ~ 1 + high_debt_version + work_experience_programming.s + (1 | session)",
prior = c(
prior(normal(0, 1), class = "b"),
prior(normal(2, 1), class = "Intercept"),
prior(exponential(1), class = "sd")
),
family = binomial(),
data = as.data.frame(d.completed),
control = list(adapt_delta = 0.95),
file = "fits/variable_names0.all.exp",
file_refit = "on_change",
seed = 20210421
)
summary(variable_names0.all.exp)
## Family: binomial
## Links: mu = logit
## Formula: var_names_new_good | trials(var_names_new_all) ~ 1 + high_debt_version + work_experience_programming.s + (1 | session)
## Data: as.data.frame(d.completed) (Number of observations: 51)
## Samples: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
## total post-warmup samples = 4000
##
## Group-Level Effects:
## ~session (Number of levels: 29)
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept) 1.76 0.58 0.80 3.09 1.00 1267 1551
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI Rhat
## Intercept 1.52 0.50 0.65 2.62 1.00
## high_debt_versionfalse 2.48 0.57 1.41 3.64 1.00
## work_experience_programming.s 0.14 0.46 -0.75 1.09 1.00
## Bulk_ESS Tail_ESS
## Intercept 2162 2855
## high_debt_versionfalse 3556 3135
## work_experience_programming.s 2823 2580
##
## Samples were drawn using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
ranef(variable_names0.all.exp)
## $session
## , , Intercept
##
## Estimate Est.Error Q2.5 Q97.5
## 6033c6fc5af2c702367b3a93 -1.4156555 1.1508646 -3.7756170 0.68891320
## 6033d69a5af2c702367b3a95 1.0231133 1.4836356 -1.4501800 4.40254725
## 6033d90a5af2c702367b3a96 1.3119868 1.3849861 -0.9318521 4.50972250
## 6034fc165af2c702367b3a98 -1.3381758 0.6576618 -2.6852293 -0.10022283
## 603500725af2c702367b3a99 -1.4778229 1.1104833 -3.6646500 0.53581138
## 603f84f15af2c702367b3a9b 0.2670556 1.6806498 -2.8793452 3.73103000
## 603f97625af2c702367b3a9d 1.3204454 1.3921900 -0.9272059 4.67857075
## 603fd5d95af2c702367b3a9e -1.4769872 1.1122240 -3.7737097 0.61350890
## 60409b7b5af2c702367b3a9f 1.2729010 1.4101308 -1.0308088 4.58686550
## 604b82b5a7718fbed181b336 -0.8770285 0.8380458 -2.5688482 0.72631785
## 604f1239a7718fbed181b33f 0.8636503 1.4567600 -1.6502992 4.11096775
## 6050c1bf856f36729d2e5218 -1.9233764 1.0428065 -4.0005750 0.01877713
## 6050e1e7856f36729d2e5219 1.2625932 1.4304418 -1.0508347 4.42910925
## 6055fdc6856f36729d2e521b 1.0103794 1.4588449 -1.3813337 4.30400475
## 60579f2a856f36729d2e521e 0.2709268 1.6971436 -2.7838095 3.94109675
## 60589862856f36729d2e521f 0.9596694 1.5427175 -1.7654190 4.39381950
## 605a30a7856f36729d2e5221 0.1788234 1.7796358 -3.1419825 3.97317025
## 605afa3a856f36729d2e5222 -1.8024174 1.2599105 -4.4497823 0.43480038
## 605c8bc6856f36729d2e5223 -0.9971662 0.9883357 -3.0160835 0.89037148
## 605f3f2d856f36729d2e5224 0.8945882 1.6091834 -2.0997973 4.45969625
## 605f46c3856f36729d2e5225 -1.5982496 0.9023868 -3.4778017 0.12623093
## 60605337856f36729d2e5226 0.9689306 1.4258568 -1.4183980 4.17233350
## 60609ae6856f36729d2e5228 1.2964548 1.3829485 -0.9727389 4.37453100
## 6061ce91856f36729d2e522e 1.2888959 1.3921476 -0.9699880 4.51305300
## 6061f106856f36729d2e5231 -1.4942213 1.0885155 -3.6722690 0.59254998
## 60672faa856f36729d2e523c 0.3079032 1.6465885 -2.7444270 3.93809675
## 6068ea9f856f36729d2e523e 1.6028083 1.4120985 -0.5332682 4.86557125
## 606db69d856f36729d2e5243 0.4692370 1.5486129 -2.3723718 3.80212675
## 6075ab05856f36729d2e5247 1.2522868 1.3845858 -1.0074265 4.56951975
plot(variable_names0.all.exp, ask = FALSE)
pp_check(variable_names0.all.exp, nsamples = 200, type = "bars")
loo(
variable_names0.all,
variable_names0.all.exp
)
## Output of model 'variable_names0.all':
##
## Computed from 4000 by 51 log-likelihood matrix
##
## Estimate SE
## elpd_loo -39.0 6.4
## p_loo 15.4 2.8
## looic 78.0 12.7
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 25 49.0% 381
## (0.5, 0.7] (ok) 16 31.4% 179
## (0.7, 1] (bad) 9 17.6% 35
## (1, Inf) (very bad) 1 2.0% 23
## See help('pareto-k-diagnostic') for details.
##
## Output of model 'variable_names0.all.exp':
##
## Computed from 4000 by 51 log-likelihood matrix
##
## Estimate SE
## elpd_loo -39.7 6.6
## p_loo 16.5 3.1
## looic 79.4 13.2
## ------
## Monte Carlo SE of elpd_loo is NA.
##
## Pareto k diagnostic values:
## Count Pct. Min. n_eff
## (-Inf, 0.5] (good) 27 52.9% 1096
## (0.5, 0.7] (ok) 11 21.6% 334
## (0.7, 1] (bad) 12 23.5% 72
## (1, Inf) (very bad) 1 2.0% 9
## See help('pareto-k-diagnostic') for details.
##
## Model comparisons:
## elpd_diff se_diff
## variable_names0.all 0.0 0.0
## variable_names0.all.exp -0.7 0.6
This means that our final model, with all data points and experience predictors, is variable_names0.all.exp
To begin interpreting the model we look at how it’s parameters were estimated. As our research is focused on how the outcome of the model is effected we will mainly analyze the \(\beta\) parameters.
mcmc_areas(
variable_names0.all.exp,
pars = c("b_high_debt_versionfalse", "b_work_experience_programming.s"),
prob = 0.95
) +
scale_y_discrete() +
scale_y_discrete(labels=c("High debt version: false", "Professional programming experience")) +
ggtitle(
"Beta parameters densities in time model",
subtitle = "Shaded region marks 95% of the density. Line marks the median"
)
We start by extracting posterior samples
scale_programming_experience <- function(x) {
(x - mean(d.completed$work_experience_programming))/ sd(d.completed$work_experience_programming)
}
unscale_programming_experience <- function(x) {
x * sd(d.completed$work_experience_programming) + mean(d.completed$work_experience_programming)
}
post_settings <- expand.grid(
high_debt_version = c("false", "true"),
session = NA,
var_names_new_all = 1000,
work_experience_programming.s = sapply(c(0, 3, 10, 25, 40), scale_programming_experience)
)
post <- posterior_predict(variable_names0.all.exp, newdata = post_settings) %>%
melt(value.name = "estimate", varnames = c("sample_number", "settings_id")) %>%
left_join(
rowid_to_column(post_settings, var= "settings_id"),
by = "settings_id"
) %>%
mutate(work_experience_programming = unscale_programming_experience(work_experience_programming.s)) %>%
select(
estimate,
high_debt_version,
work_experience_programming
)%>%
mutate(estimate = estimate/1000)
ggplot(post %>% filter(work_experience_programming == 10), aes(x=estimate, fill = high_debt_version)) +
geom_density(alpha = 0.5) +
scale_fill_manual(
name = "Debt version",
labels = c("Low debt", "High debt"),
values = c("lightblue", "darkblue")
) +
facet_grid(rows = vars(work_experience_programming)) +
labs(
title = "Rate of good variable naming",
x = "Rate",
y = "Density"
)
ggplot(post, aes(x=estimate, fill = high_debt_version)) +
geom_density(alpha = 0.5) +
scale_fill_manual(
name = "Debt version",
labels = c("Low debt", "High debt"),
values = c("lightblue", "darkblue")
) +
facet_grid(rows = vars(work_experience_programming)) +
labs(
title = "Rate of good variable naming / professional programmign experience",
x = "Rate",
y = "Density"
)
scale_programming_experience <- function(x) {
(x - mean(d.completed$work_experience_programming))/ sd(d.completed$work_experience_programming)
}
unscale_programming_experience <- function(x) {
x * sd(d.completed$work_experience_programming) + mean(d.completed$work_experience_programming)
}
post_settings <- expand.grid(
high_debt_version = c("false", "true"),
session = NA,
var_names_new_all = 10,
work_experience_programming.s = sapply(c(10), scale_programming_experience)
)
post <- posterior_predict(variable_names0.all.exp, newdata = post_settings) %>%
melt(value.name = "estimate", varnames = c("sample_number", "settings_id")) %>%
left_join(
rowid_to_column(post_settings, var= "settings_id"),
by = "settings_id"
) %>%
mutate(work_experience_programming = unscale_programming_experience(work_experience_programming.s)) %>%
select(
estimate,
high_debt_version,
work_experience_programming
)
levels(post$high_debt_version) <- c("Low debt version", "High debt version")
ggplot(post, aes(x=estimate, fill = high_debt_version)) +
geom_bar() +
facet_grid(rows = vars(high_debt_version)) +
scale_fill_manual(
name = "Debt version",
labels = c("Low debt version", "High debt version"),
values = c("lightblue", "darkblue")
) +
labs(
title = "Variable naming (10 named variables)",
x = "Number of good variable names",
y = "Rate of occurrence"
) +
theme_minimal() +
scale_x_continuous(breaks = c(0,1,2,3,4,5,6,7,8,9,10), labels = c(0,1,2,3,4,5,6,7,8,9,10)) +
scale_y_continuous(limits = NULL, breaks = c(500,1000,1500,2000,2500), labels = c("10%","20%","30%","40%","50%")) + theme(legend.position = "hidden")
d.high <- 10 - (post %>% filter(high_debt_version == "High debt version") %>% pull(estimate))
d.low <- 10 - (post %>% filter(high_debt_version == "Low debt version") %>% pull(estimate))
sum(d.high) / sum(d.low)
## [1] 5.453859
more than 5 times more likely to introduce none-descriptive variable names